public class work {
    //求两个数的最大值max2
    public static int max2(int x,int y){
        if(x>y){
            return x;
        }else{
            return y;
        }
//        return x>y?x:y;
    }

    //求两个数的最大值max3
    public static int max3(int x,int y,int z){
        if(max2(x,y)>z){
            return max2(x,y);
        }else{
            return z;
        }
        //int max=max2(x,y);
        // return  max2(max,z)
    }
    public static int max(int x,int y){
        if(x>y){
            return x;
        }else{
            return y;
        }
    }

    //求两个数的最大值max3
    public static int max(int x,int y,int z){
        if(max2(x,y)>z){
            return max2(x,y);
        }else{
            return z;
        }
    }
    //求n的阶乘
    public static int fac(int n){
        int ret = 1;
        for(int i = 1; i<=n;i++){
            ret*=i;
        }
        return ret;
    }
    //递归求n的阶乘
    public static int facFun(int n){
        int sum = 0;
        if(n == 1){
            return 1;
        }
        sum=n*facFun(n-1);
        return sum;
    }

    //求阶乘和
    public static int facSum(int n){
        int sum = 0;
        for (int i =1;i<=n;i++){
            sum +=fac(i);
        }
        return sum;
    }
    //斐波那契数列的第n项(迭代实现)
    public static int fib(int n){
        if(n==1){
            return 0;
        }
        if(n==2){
            return 1;
        }
        int f1 = 0;
        int f2 = 1;
        int f3 = 1;
       for(int i = 3;i<=n;i++){
           f3 = f2+f1;
           f1 = f2;
           f2 = f3;
       }
       return  f3;
    }

    //两个整数的和
    public static int add(int x,int y){
        return x+y;
    }
    //三个小数的和
    public static double add(double x,double y,double z){
        return x+y+z;
    }

    //汉诺塔
    public static void move(char a,char b){
        System.out.println(a+"->"+b);
    }
    public static void hanNuo(int n,char a,char b,char c){
        if(n ==1){
            move(a,c);
        }else{
            hanNuo(n-1,a,b,c);
            move(a,c);
            hanNuo(n-1,b,a,c);
        }
    }
    public static void main(String[] args) {
        hanNuo(3,'a','b','c');
//        System.out.println(max2(5, 6));
//        System.out.println(max3(45, 56, 15));
//        System.out.println(fac(5));
//        System.out.println(facFun(5));
//        System.out.println(facSum(5));
//        System.out.println(fib(7));
//        System.out.println(add(5, 6));
//        System.out.println(add(4.0, 5.5, 7.9));

    }
}
